package com.lagou.wwyan.service.impl;

import com.lagou.wwyan.service.HelloService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;

@Service(timeout = 3000)
public class HelloServiceImpl implements HelloService {
    private Random random = new Random();
    public String sayHelloA() {
        randomSleep("sayHelloA");
        return "你好 A ！";
    }

    public String sayHelloB() {
        randomSleep("sayHelloB");
        return "你好 B ！";
    }

    public String sayHelloC() {
        randomSleep("sayHelloC");
        return "你好 C ！";
    }

    private void randomSleep( String name){
        try {
            long millis = random.nextInt(100);
            System.out.println("sleep:"+name+":"+millis);
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
